import { merge } from "utils";
import type { RequestDefaultConfig } from "../request/request.type";
function curringHttp(method: "GET" | "POST" | "none") {
    let config: RequestDefaultConfig = {
        method: method,
    };
    // 添加 模块名称
    return (modulePath: string, moduleConfig?: RequestDefaultConfig) => {
        if (moduleConfig) {
            config = merge(config, moduleConfig);
        }
        // 子路径
        return (path: string) => {
            // 添加path
            config.path = `${modulePath}${path}`;
            return (payload: Record<string, any>, runConfig?: RequestDefaultConfig) => {
                config.data = payload;
                // 合并
                let finalConfig = merge(config, runConfig ?? {});
                return finalConfig;
            };
        };
    };
}

const API_Call_Get = curringHttp("GET");
const API_Call_Post = curringHttp("POST");
const API_Call_Cloud = curringHttp("none");
export { API_Call_Get, API_Call_Post, API_Call_Cloud };
